The Fab Academy 2014 Digital Fabrication Laboratory. Department of Architecture. Institute of Technology. EPS-CEU San Pablo CEU University |
Adolfo Gutiérrez Sánchez Architect |
|||
Home | Portfolio | Files |
INTERFACE & APPLICATION PROGRAMMING |
The assignment The assignment for this week was to write a code for a program that can interact with an Input or an Output device. The chosen software to write the code is Processing, because I have already used it and I want to improve my level a little better. The idea is to control two different servos with the FabDuino board using a program written in Processing. The design will be two different buttons that control the servos and the buttons and some "LED lights" will interact with the program. |
Processing code The idea of before starting to write the code in PROCESSING, is to create a two buttons interface where I can interact between the Arduino board with two servos connected and the computer screen. The graphics will be very simple, but will always tell you, wether the servo 1 is connected and working or is the servo 2 the one is working. When the button 1 is pressed, the button highlights and starts a counter that will switch between the ON and OFF leds. If the button 2 is pressed, the same process starts. There is no limitation and the buttons do not interfere the connections if both of them are On or OFF. |
|
1. SET ALL THE VARIABLES import cc.arduino.*; float bx; int count; color White = color(255,255,255);
int ancho = 1000; int WidthRectangle = 100; |
|
2. SET THE VOID SETUP: OPEN THE SERIAL PORT AND SET MORE VARIABLES void setup() }
3. SET THE VOID DRAW: SET THE BACKGROUND AND ALL THE GRAPHICS THAT ARE GOING TO BE DISPLAYED, AND ALL THE "IF" RULES THAT WILL START WITH THE PROGRAM void draw() text("To move Servo 2,", (ancho/5), (alto/3)*2); 4. SET THE VOID MOUSE PRESSED AND MOUSE DRAGGED: SET THESE FUCNTIONS THAT WILL OPEN WHEN THE MOUSE PRESSES ONE O THE BUTTONS void mousePressed() { void mouseDragged() { void mouseReleased() { |
|
Processing code The next step is to set the Arduino code that will run in the microcontroller of the FabDuino. This code will transmit the data collected fro the Processing code and will transform it into movement. 1. SET THE INITIAL VARIABLES int servo1 = 7; int angle; int incomingByte;
2. SET THE VOID SETUP: WILL START THE SERIAL PORT AND SET THE PINS OF TH SERVOS AS AN OUTPUT void setup()
2. SET THE VOID LOOP: SET THE ROTATION OF THE SERVO ACCORDING TO THE MOUSE INTERACTION IN THE PROCESSING INTERFACE void loop ()
|
|